﻿using EnetaMvc.ApplicationServices;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace EnetaMvc.Web.Controllers
{
    public class TinyMceExampleController : Controller
    {
        private readonly IFileService _fileService;

        public TinyMceExampleController(IFileService fileService)
        {
            _fileService = fileService;
        }

        public ActionResult Index()
        {
            return View();
        }

        //[HttpPost]
        //public string UploadImage(HttpPostedFileBase imageName)
        //{
        //    byte[] bytes = new byte[imageName.InputStream.Length];
        //    imageName.InputStream.Read(bytes, 0, bytes.Length);

        //    string path = _fileService.SaveEditorImage(bytes);
        //    if (path[0] == '\\')
        //        path = path.Substring(1);
        //    return "<div id=\"image\">" + path + "</div>";
        //}

        [HttpPost]
        public string UploadImageToBlob(HttpPostedFileBase imageName)
        {
            //TODO: File client should also support local paths
            //string path = _fileService.SaveEditorImageToBlob(imageName.InputStream, imageName.ContentType);
            var path = "";
            return "<div id=\"image\">" + path + "</div>";
        }
    }
}
